<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" 
  xmlns:fn="http://www.w3.org/2005/xpath-functions/" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output omit-xml-declaration="yes"/>
  <xsl:param name="rulesetruntime"/>
  <xsl:param name="transtype"/>
  <xsl:param name="transtypetc"/>
  <xsl:param name="transsubtype"/>
  <xsl:param name="transsubtypetc"/>
  <xsl:param name="transexedate"/>
  <xsl:param name="transexetime"/>
  <xsl:param name="schemaresponse"/>
  <xsl:param name="version"/>
  
  <xsl:template match="/">
    <MessageValidationResponse>
      <MessageValidationInfo>
        <TransType>
          <xsl:attribute name="tc">
            <xsl:value-of select="$transtypetc"/>
          </xsl:attribute>
          <xsl:value-of select="$transtype"/>
        </TransType>
        <TransSubType>
          <xsl:attribute name="tc">
            <xsl:value-of select="$transsubtypetc"/>
          </xsl:attribute>
          <xsl:value-of select="$transsubtype"/>
        </TransSubType>
        <TransExeDate>
          <xsl:value-of select="$transexedate"/>
        </TransExeDate>
        <TransExeTime>
          <xsl:value-of select="$transexetime"/>
        </TransExeTime>
        <MTSVersionInfo>
          <xsl:value-of select="$version"/>
        </MTSVersionInfo>
      </MessageValidationInfo>
      <xsl:copy-of select="$schemaresponse"/>
        <xsl:apply-templates />
    </MessageValidationResponse>
    
  </xsl:template>

  <xsl:template match="*|@*|node()">
      <xsl:copy>
        <xsl:apply-templates select="*|@*|node()"/>
      </xsl:copy>
  </xsl:template>
    
  <xsl:template match="TotalRuleSetRules">
    <ElapsedTime>
      <xsl:value-of select="$rulesetruntime"/>
    </ElapsedTime>
    <xsl:copy>
      <xsl:apply-templates select="*|@*|node()"/>
    </xsl:copy>
    <TotalRulesRun>
      <xsl:value-of select="count(//RuleEvent)"/>
    </TotalRulesRun>
    <TotalSuccessfulRules>
      <xsl:value-of select="count(//RuleEvent/TransResult/ResultCode[@tc='1'])"/>
    </TotalSuccessfulRules>
    <TotalFailedRules>
      <xsl:value-of select="count(//RuleEvent/TransResult/ResultCode[@tc='5'])"/>
    </TotalFailedRules>
   
  </xsl:template>
</xsl:stylesheet>